#include "GameCredit.h"

GameCredit::GameCredit(
	WINAPP*  a_app,
	WINFPS*  a_fps,
	WINTIME* a_time,
	D3DF*    a_d3d,
	DINF*    a_din,
	bool     a_renew)
{
	m_app  = a_app;
	m_fps  = a_fps;
	m_time = a_time;
	m_d3d  = a_d3d;
	m_din  = a_din;

	strcpy_s(m_name,32,"GameCredit");
	m_selfId = GAMECREDIT;
	m_swapId = GAMECREDIT;
	m_completed = false;
	m_renew = a_renew;
}

void GameCredit::init()
{
	m_credit.init(FRAMEWORKS_MEM_REG);
	m_credit.initTexture("textures/creditsList.png",TEX_TL,V2D_ZERO,V2D_ONES,0);
	m_credit.update();

	m_back.init(FRAMEWORKS_MEM_REG);
	m_back.initTexture("textures/back.png",TEX_BR,V2D_ZERO,V2D_ONES,0);
	m_back.setTrn(V2DF(WINW,WINH)+V2DF(-32,-32));

	m_back.onIdle([&](){m_back.setScl(V2DF(1,1));});
	m_back.onHover([&](){m_back.setScl(V2DF(1.08f,1.08f));});
	m_back.onClick([&](){m_swapId=GAMEMENU;m_completed=true;});
}

void GameCredit::reset()
{

}

void GameCredit::release()
{

}

void GameCredit::input()
{
	m_din->acquire();

	m_back.input();
}

void GameCredit::update()
{
	m_back.update();
}

void GameCredit::draw()
{
	m_d3d->drawBegin();

	m_credit.draw();
	m_back.draw();

	m_d3d->drawText(m_name,V2D_ZERO,CL_RED);
	m_d3d->drawEnd();
}

void GameCredit::pre()
{
	m_fps->update();
	m_time->update();
}

void GameCredit::post()
{

}